package com.A21MobileSales;

import java.io.IOException;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.Window;

import com.A21MobileSales.DataBase.DatabaseHelper;

public class SplashScreen extends Activity {

	private long splashTime = 2000;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.splash_screen);

		DatabaseHelper myDbHelper = new DatabaseHelper(SplashScreen.this);
		try {

			myDbHelper.createDataBase();
			myDbHelper.openDataBase();

		} catch (IOException ioe) {

			throw new Error("Unable to create database");

		}
		new Handler().postDelayed(new Runnable() {
			public void run() {
				Intent mainIntent = new Intent(SplashScreen.this,
						LoginActivity.class);
				startActivity(mainIntent);
				finish();
				overridePendingTransition(R.anim.mainfadein,
						R.anim.splashfadeout);
			}
		}, splashTime);
	}
}
